home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_bas / basupd10 / curdir$.asm < prev    next >
Assembly Source File  |  1992-06-18  |  3KB  |  88 lines

  1. comment #
  2.  
  3.    +----------------------------------------------------------------------+
  4.    |                                                                      |
  5.    |        PBClone  Copyright (c) 1990-1992  Thomas G. Hanlin III        |
  6.    |                                                                      |
  7.    |                        assembled with MASM 6.0                       |
  8.    |                                                                      |
  9.    |           COMMERCIAL PRODUCT: NOT FOR PUBLIC DISTRIBUTION            |
  10.    |                                                                      |
  11.    +----------------------------------------------------------------------+
  12.  
  13. #
  14.  
  15. public  CURDIR
  16.  
  17.  
  18.  
  19. .model medium
  20.  
  21.  
  22.  
  23. .DATA
  24.  
  25.  
  26.  
  27. String    db "x:\"                ; result string (Drive:\PathFromRoot)
  28.           db 64 dup(?)
  29.  
  30. StrHead   dw ?                    ; length of result string
  31.           dw offset DGROUP:String ; pointer to result string
  32.  
  33.  
  34.  
  35. .CODE
  36.  
  37.  
  38.  
  39. CURDIR        proc           far       ; get current subdir on a given drive
  40.               push           bp             ;
  41.               mov            bp,sp          ;
  42.               push           si             ;
  43.               push           di             ;
  44.                                             ;
  45.               push           ds             ;
  46.               pop            es             ;
  47.               xor            dx,dx          ;
  48.               mov            bx,6[bp]       ; drive letter
  49.               mov            cx,[bx]        ;
  50.               mov            bx,2[bx]       ;
  51.               mov            al,[bx]        ;
  52.               or             cx,cx          ; was there really a drive letter?
  53.               jnz            GetSubDir      ;   yep, rock 'n' roll
  54.                                             ;
  55.               mov            ah,19h         ; get default drive
  56.               int            21h            ;
  57.               add            al,"A"         ; convert to letter
  58.                                             ;
  59. GetSubDir:    mov            String,al      ; set drive letter into result
  60.               mov            dl,al          ;
  61.               and            dl,1Fh         ;
  62.               lea            si,DGROUP:String+3
  63.               mov            di,si          ;
  64.               mov            ah,47h         ; get current directory
  65.               int            21h            ;
  66.               jc             Error          ;
  67.               mov            cx,64          ; max subdir length
  68.               mov            al,ch          ;
  69.               repnz          scasb          ; scan up to 64b until NUL
  70.               mov            ax,66          ;
  71.               sub            ax,cx          ;
  72.                                             ;
  73. Done:         mov            StrHead,ax     ; set length of subdir string
  74.                                             ;
  75.               lea            ax,DGROUP:StrHead
  76.               pop            di             ;
  77.               pop            si             ;
  78.               pop            bp             ;
  79.               ret            2              ;
  80.                                             ;
  81. Error:        xor            ax,ax          ; set subdir length to null
  82.               jmp            Done           ;
  83. CURDIR        endp                     ; get current subdir on a given drive
  84.  
  85.  
  86.  
  87.               end
  88.